// @ts-ignore
/* eslint-disable */
import { request } from 'umi';
import { ActiveCodeListItem, ActiveOrderListItem, TableListItem, MpConfigItem } from './data';
import store from 'store';

/** 获取规则列表 GET /api/get_config_list */
export async function getConfigList(
  params: {
    /** 当前的页码 */
    current?: number;
    /** 页面的容量 */
    pageSize?: number;
  },
  options?: { [key: string]: any },
  corp_id?: string,
) {
  return request<{
    data: TableListItem[];
    /** 列表的内容总数 */
    total?: number;
    success?: boolean;
  }>('/api/get_config_list', {
    method: 'GET',
    params: {
      ...params,
      corp_id,
    },
    ...(options || {}),
  });
}

/** 新建规则 PUT /api/rule */
export async function updateRule(data: { [key: string]: any }, options?: { [key: string]: any }) {
  return request<TableListItem>('/api/rule', {
    data,
    method: 'PUT',
    ...(options || {}),
  });
}

/** 新建规则 POST /api/create_config */
export async function create_mp_config(
  data: { [key: string]: any },
  options?: { [key: string]: any },
) {
  return request<TableListItem>('/api/create_mp_config', {
    data,
    method: 'POST',
    ...(options || {}),
  });
}
/** 新建规则 POST /api/create_config */
export async function update_mp_config(
  data: { [key: string]: any },
  options?: { [key: string]: any },
) {
  return request<TableListItem>('/api/update_mp_config', {
    data,
    method: 'POST',
    ...(options || {}),
  });
}

/** 删除规则 DELETE /api/rule */
export async function removeRule(data: { key: number[] }, options?: { [key: string]: any }) {
  return request<Record<string, any>>('/api/rule', {
    data,
    method: 'DELETE',
    ...(options || {}),
  });
}

/** 获取规则列表 GET /api/get_employee_list */
export async function getEmployeeList(
  params: {
    /** 当前的页码 */
    current?: number;
    /** 页面的容量 */
    pageSize?: number;
  },
  options?: { [key: string]: any },
  corp_id?: string,
) {
  return request<{
    data: EmployeeListItem[];
    /** 列表的内容总数 */
    total?: number;
    success?: boolean;
  }>('/api/get_employee_list' + '?corp_id=' + corp_id, {
    method: 'GET',
    params: {
      ...params,
      corp_id,
    },
    ...(options || {}),
  });
}

/** 新建规则 POST /api/push_config */
export async function pushConfig(data: { [key: string]: any }, options?: { [key: string]: any }) {
  if (options === undefined) {
    const token: string | undefined = store.get('appToken');
    options = {
      headers: {
        Authorization: token ? token : '',
      },
    };
  }
  return request<TableListItem>('/api/push_config', {
    data,
    method: 'POST',
    ...(options || {}),
  });
}

/** 新建规则 POST /api/updateConfig */
export async function updateConfig(data: { [key: string]: any }, options?: { [key: string]: any }) {
  if (options === undefined) {
    const token: string | undefined = store.get('appToken');
    options = {
      headers: {
        Authorization: token ? token : '',
      },
    };
  }
  return request<TableListItem>('/api/update_config', {
    data,
    method: 'POST',
    ...(options || {}),
  });
}

/** 新建规则 POST /api/update_employee */
export async function updateEmployee(
  data: { [key: string]: any },
  options?: { [key: string]: any },
) {
  if (options === undefined) {
    const token: string | undefined = store.get('appToken');
    options = {
      headers: {
        Authorization: token ? token : '',
      },
    };
  }
  return request<TableListItem>('/api/update_employee', {
    data,
    method: 'POST',
    ...(options || {}),
  });
}

/** 获取规则列表 GET /api/get_mp_config/:config_id */
export async function getMpConfigById(
  corpId?: string,
  config_id?: string,
  options?: { [key: string]: any },
) {
  if (options === undefined) {
    const token: string | undefined = store.get('appToken');
    options = {
      headers: {
        Authorization: token ? token : '',
      },
    };
  }
  return request<{
    data: MpConfigItem;
    /** 列表的内容总数 */
    total?: number;
    success?: boolean;
  }>('/api/get_mp_config/' + config_id + '?corp_id=' + corpId, {
    method: 'GET',
    ...(options || {}),
  });
}

/** 获取规则列表 GET /api/get_active_order_list */
export async function getActiveOrderList(corp_id?: string, options?: { [key: string]: any }) {
  if (options === undefined) {
    const token: string | undefined = store.get('appToken');
    options = {
      headers: {
        Authorization: token ? token : '',
      },
    };
  }
  return request<{
    data: ActiveOrderListItem[];
    /** 列表的内容总数 */
    total?: number;
    success?: boolean;
  }>('/api/get_active_order_list', {
    method: 'GET',
    ...(options || {}),
  });
}

/** 获取规则列表 GET /api/get_active_code_list */
export async function getActiveCodeList(
  corp_id?: string,
  order_id?: string,
  options?: { [key: string]: any },
) {
  if (options === undefined) {
    const token: string | undefined = store.get('appToken');
    options = {
      headers: {
        Authorization: token ? token : '',
      },
    };
  }
  return request<{
    data: ActiveCodeListItem[];
    /** 列表的内容总数 */
    total?: number;
    success?: boolean;
  }>('/api/get_active_code_list', {
    method: 'GET',
    params: {
      corp_id,
      order_id,
    },
    ...(options || {}),
  });
}

/** 新建规则 POST /api/active_employee */
export async function ActiveEmployee(
  code: string,
  user_id: string,
  corp_id: string,
  options?: { [key: string]: any },
) {
  if (options === undefined) {
    const token: string | undefined = store.get('appToken');
    options = {
      headers: {
        Authorization: token ? token : '',
      },
    };
  }
  return request<TableListItem>('/api/active_employee', {
    method: 'POST',
    data: {
      code,
      user_id,
      corp_id,
    },
    ...(options || {}),
  });
}

/** 获取规则列表 GET /api/get_employee_list */
export async function GetMpConfigList(
  params: {
    /** 当前的页码 */
    current?: number;
    /** 页面的容量 */
    pageSize?: number;
  },
  options?: { [key: string]: any },
  corp_id?: string,
) {
  return request<{
    data: TableListItem[];
    /** 列表的内容总数 */
    total?: number;
    success?: boolean;
  }>('/api/get_mp_config_list', {
    method: 'GET',
    params: {
      ...params,
      corp_id,
    },
    ...(options || {}),
  });
}
